package demo3;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-07-03
 * Time: 21:46
 */
class Person{
    public String name;
    public int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Test {
    public static void main(String[] args) {
/*        String str = "hello world hello xx";
        String[] arr = str.split(" ");
        System.out.println(Arrays.toString(arr));

        System.out.println("=============");*/

        String str2 = "192.168.0.0.1";
        String[] arr1 = str2.split("\\.");
        for (int i = 0; i < arr1.length; i++) {
            System.out.println(arr1[i]);
        }
    }
    public static void main4(String[] args) {
        String str1 = "abcabcabcdeabcdef";
        String ret = str1.replaceFirst("ab","zzz");
        System.out.println(ret);
        System.out.println("=========================");
        String ret1 = str1.replaceAll("ab","zzz");
        System.out.println(ret1);
        System.out.println("=========================");

        String ret2 = str1.replace("ab","zzz");
        System.out.println(ret2);
        System.out.println("=========================");

        String ret3 = str1.replace('a','p');
        System.out.println(ret3);
        System.out.println("=========================");

    }
    public static void main3(String[] args) {
        String str = "hello";
        String ret = str.toUpperCase();
        System.out.println(ret);

        System.out.println("===============");

        String str2 = "ABCDE";
        String ret1 = str2.toLowerCase();
        System.out.println(ret1);

        System.out.println("===============");

        String str4 = "hello world";
        char[] st = str4.toCharArray();
        System.out.println(Arrays.toString(st));

        System.out.println("===============");

        String rett = String.format("%d %d",10,20);
        System.out.println(rett);
    }
    public static void main2(String[] args) {
        String s1 = String.valueOf(1234);
        System.out.println(s1);
        String s2 = String.valueOf(new Person("张三",15));
        System.out.println(s2);

        System.out.println("=================");

        int data = Integer.valueOf("123");
        System.out.println(data);

        int data1 = Integer.parseInt("123");
        System.out.println(data1);
    }
    public static void main1(String[] args) {
        String str1 = "hello";
        char ch = str1.charAt(1);
        System.out.println(ch);

        System.out.println(str1.indexOf("l"));
        System.out.println(str1.indexOf("e",3));

        System.out.println(str1.indexOf("ll"));
        System.out.println("================");

        System.out.println(str1.lastIndexOf("l"));
        System.out.println(str1.lastIndexOf("l",2));
    }
}
